﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.S.DataBase.Traceability.Infrastructure.Interface
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    public interface IBaseRepository<T> where T : class
    {
        Task<T> GetAsync(string sql, object param = null);
        Task<int> Update(T entity);
        Task<IEnumerable<T>> GetAllAsync(string sql, object param = null);
        Task<IEnumerable<TReturn>> GetAllAsync<TReturn>(string sql, object param = null);
        Task<int> AddRanges(List<T> entitys);
        Task<int> DeleteRemove(List<T> entity);
        Task<int> Delete(T entitys);
        Task<int> UpdateRanhes(List<T> entitys);
        IEnumerable<T> GetAllRanhes();

        // 批量操作
        Task<int> InsertRangeAsync(IEnumerable<T> entities);
        Task<int> UpdateRangeAsync(IEnumerable<T> entities);
        Task<int> DeleteRangeAsync(IEnumerable<T> entities);


        // 事务批量操作
        Task<int> InsertRangeWithTransactionAsync(IEnumerable<T> entities);
        Task<int> UpdateRangeWithTransactionAsync(IEnumerable<T> entities);
        Task<int> DeleteRangeWithTransactionAsync(IEnumerable<T> entities, Func<T, object> getId);
        // 新增 ExecuteScalarAsync 方法
        Task<TResult> ExecuteScalarAsync<TResult>(string sql, object param = null);
    }
}